package com.rizzo.analytics.services.repo;

import com.rizzo.analytics.domain.trigger.TresholdType;
import com.rizzo.analytics.domain.trigger.Trigger;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface TriggerRepository extends PagingAndSortingRepository<Trigger, Long>, JpaSpecificationExecutor {

    List<Trigger> findByServiceContainingIgnoreCase(@Param("service") String service, Pageable pageable);

    List<Trigger> findByTresholdType(@Param("tresholdType") TresholdType tresholdType, Pageable pageable);

    List<Trigger> findByTresholdTypeAndTresholdGreaterThan(@Param("tresholdType") TresholdType tresholdType,
                                                           @Param("treshold") Double treshold, Pageable pageable);

}
